<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //构造函数创建对象
/*         function Person(name, age){
            this.name = name;
            this.age = age;
            this.sayName = fun;
        }
        function fun(){
            alert("我是" + this.name + "," + this.age + "岁");
        }

        var per1 = new Person(11,1);
        per1.sayName(); */

        //改为原型
/*         function Person(name, age){
            this.name = name;
            this.age = age;
        };
        Person.prototype.sayName = function(){
            alert("我是" + this.name + "," + this.age + "岁");
        }
        var per1 = new Person(11,1);
        per1.sayName();
        var per2 = new Person(22,2);
        per2.sayName(); */
    </script>
</body>
</html>